use crate::data_channels::{message::Message, ui_request::ui_request_response};

pub async fn execute_command_request(
    peer_id: &String,
    request_message: Message,
    timeout: u64,
) -> anyhow::Result<Message> {
    //封装请求，请求前端
    let request =
        String::from_utf8(request_message.data).map_err(|err| anyhow::anyhow!("{}", err))?;
    let response = ui_request_response(peer_id, request, timeout).await?;
    let message = Message::uicmd_response(response.into_bytes());
    Ok(message)
}
